
Friend Class TestingForm
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btnTBSwitch As System.Windows.Forms.Button
    Friend WithEvents btnThrow As System.Windows.Forms.Button
    Friend WithEvents btnShowTasks As System.Windows.Forms.Button
    Friend WithEvents btnShowResize As System.Windows.Forms.Button
    Friend WithEvents btnTrain As System.Windows.Forms.Button
    Friend WithEvents XpButton1 As System.Windows.Forms.Button
    Friend WithEvents lb As System.Windows.Forms.ListBox
    Friend WithEvents btnEngineStatus As System.Windows.Forms.Button
    Friend WithEvents tbSwitchNum As System.Windows.Forms.TextBox
    Friend WithEvents btnShowTasksSwitch As System.Windows.Forms.Button
    Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox
    Friend WithEvents chkEnableQS As System.Windows.Forms.CheckBox
    Friend WithEvents chkSpeechEnabledAtStartup As System.Windows.Forms.CheckBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnTBSwitch = New System.Windows.Forms.Button
        Me.btnThrow = New System.Windows.Forms.Button
        Me.btnShowTasks = New System.Windows.Forms.Button
        Me.btnShowResize = New System.Windows.Forms.Button
        Me.btnTrain = New System.Windows.Forms.Button
        Me.XpButton1 = New System.Windows.Forms.Button
        Me.lb = New System.Windows.Forms.ListBox
        Me.btnEngineStatus = New System.Windows.Forms.Button
        Me.tbSwitchNum = New System.Windows.Forms.TextBox
        Me.btnShowTasksSwitch = New System.Windows.Forms.Button
        Me.GroupBox4 = New System.Windows.Forms.GroupBox
        Me.chkEnableQS = New System.Windows.Forms.CheckBox
        Me.chkSpeechEnabledAtStartup = New System.Windows.Forms.CheckBox
        Me.GroupBox4.SuspendLayout()
        Me.SuspendLayout()
        '
        'btnTBSwitch
        '
        Me.btnTBSwitch.Location = New System.Drawing.Point(20, 255)
        Me.btnTBSwitch.Name = "btnTBSwitch"
        Me.btnTBSwitch.TabIndex = 19
        Me.btnTBSwitch.Text = "tbSwitch"
        '
        'btnThrow
        '
        Me.btnThrow.Location = New System.Drawing.Point(10, 16)
        Me.btnThrow.Name = "btnThrow"
        Me.btnThrow.Size = New System.Drawing.Size(184, 23)
        Me.btnThrow.TabIndex = 0
        Me.btnThrow.Text = "throw exception"
        '
        'btnShowTasks
        '
        Me.btnShowTasks.Location = New System.Drawing.Point(25, 222)
        Me.btnShowTasks.Name = "btnShowTasks"
        Me.btnShowTasks.Size = New System.Drawing.Size(184, 23)
        Me.btnShowTasks.TabIndex = 0
        Me.btnShowTasks.Text = "Show tasks"
        '
        'btnShowResize
        '
        Me.btnShowResize.Location = New System.Drawing.Point(10, 80)
        Me.btnShowResize.Name = "btnShowResize"
        Me.btnShowResize.Size = New System.Drawing.Size(184, 23)
        Me.btnShowResize.TabIndex = 1
        Me.btnShowResize.Text = "Resize Preview"
        '
        'btnTrain
        '
        Me.btnTrain.Location = New System.Drawing.Point(10, 112)
        Me.btnTrain.Name = "btnTrain"
        Me.btnTrain.Size = New System.Drawing.Size(184, 23)
        Me.btnTrain.TabIndex = 6
        Me.btnTrain.Text = "Show commands"
        '
        'XpButton1
        '
        Me.XpButton1.Location = New System.Drawing.Point(10, 144)
        Me.XpButton1.Name = "XpButton1"
        Me.XpButton1.Size = New System.Drawing.Size(184, 23)
        Me.XpButton1.TabIndex = 7
        Me.XpButton1.Text = "Train Commands"
        '
        'lb
        '
        Me.lb.Location = New System.Drawing.Point(340, 2)
        Me.lb.Name = "lb"
        Me.lb.Size = New System.Drawing.Size(120, 316)
        Me.lb.TabIndex = 8
        '
        'btnEngineStatus
        '
        Me.btnEngineStatus.Location = New System.Drawing.Point(12, 179)
        Me.btnEngineStatus.Name = "btnEngineStatus"
        Me.btnEngineStatus.Size = New System.Drawing.Size(184, 23)
        Me.btnEngineStatus.TabIndex = 20
        Me.btnEngineStatus.Text = "Get Engine Status"
        '
        'tbSwitchNum
        '
        Me.tbSwitchNum.Location = New System.Drawing.Point(136, 266)
        Me.tbSwitchNum.Name = "tbSwitchNum"
        Me.tbSwitchNum.TabIndex = 21
        Me.tbSwitchNum.Text = ""
        '
        'btnShowTasksSwitch
        '
        Me.btnShowTasksSwitch.Location = New System.Drawing.Point(21, 286)
        Me.btnShowTasksSwitch.Name = "btnShowTasksSwitch"
        Me.btnShowTasksSwitch.Size = New System.Drawing.Size(114, 23)
        Me.btnShowTasksSwitch.TabIndex = 22
        Me.btnShowTasksSwitch.Text = "Show Tasks Switch"
        '
        'GroupBox4
        '
        Me.GroupBox4.Controls.Add(Me.chkEnableQS)
        Me.GroupBox4.Controls.Add(Me.chkSpeechEnabledAtStartup)
        Me.GroupBox4.Location = New System.Drawing.Point(29, 333)
        Me.GroupBox4.Name = "GroupBox4"
        Me.GroupBox4.Size = New System.Drawing.Size(336, 114)
        Me.GroupBox4.TabIndex = 27
        Me.GroupBox4.TabStop = False
        Me.GroupBox4.Text = "GroupBox4"
        '
        'chkEnableQS
        '
        Me.chkEnableQS.Location = New System.Drawing.Point(22, 74)
        Me.chkEnableQS.Name = "chkEnableQS"
        Me.chkEnableQS.Size = New System.Drawing.Size(228, 30)
        Me.chkEnableQS.TabIndex = 24
        Me.chkEnableQS.Text = "Enable QuickSwitch voice commands"
        '
        'chkSpeechEnabledAtStartup
        '
        Me.chkSpeechEnabledAtStartup.Location = New System.Drawing.Point(24, 40)
        Me.chkSpeechEnabledAtStartup.Name = "chkSpeechEnabledAtStartup"
        Me.chkSpeechEnabledAtStartup.Size = New System.Drawing.Size(200, 24)
        Me.chkSpeechEnabledAtStartup.TabIndex = 25
        Me.chkSpeechEnabledAtStartup.Text = "Enable Speech on QS startup"
        '
        'TestingForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(639, 543)
        Me.Controls.Add(Me.GroupBox4)
        Me.Controls.Add(Me.btnShowTasksSwitch)
        Me.Controls.Add(Me.tbSwitchNum)
        Me.Controls.Add(Me.btnEngineStatus)
        Me.Controls.Add(Me.btnTBSwitch)
        Me.Controls.Add(Me.lb)
        Me.Controls.Add(Me.XpButton1)
        Me.Controls.Add(Me.btnTrain)
        Me.Controls.Add(Me.btnShowResize)
        Me.Controls.Add(Me.btnShowTasks)
        Me.Controls.Add(Me.btnThrow)
        Me.Name = "TestingForm"
        Me.Text = "TestingForm"
        Me.GroupBox4.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region


    'Private Sub btnShowResize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowResize.Click
    '    Dispatch.ShowResizeWindow()
    'End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dispatch.ExitApplication()
    End Sub

    Private Sub btnThrow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThrow.Click
        Throw New ApplicationException("Test")
    End Sub

    Private Sub btnTrain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Debug.WriteLine(Dispatch.SpeechMenus(0).Def.Name)
        lb.DataSource = Dispatch.SpeechMenus
    End Sub

    Private Sub XpButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not lb.SelectedItem Is Nothing Then
            Dispatch.SpeechMenus(lb.SelectedIndex).IVMenu.TrainMenuDlg(Dispatch.Handle.ToInt32, "Training")
        End If
    End Sub

    Public ReadOnly Property Dispatch() As CommandDispatch
        Get
            Return CommandDispatch.DefaultInstance
        End Get
    End Property

    Private Sub btnShowTasks_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowTasks.Click
        If My.MySettings.Default.SpeechEnabledAtStartup Then
            Dim cmdnum As Integer
            For ii As Integer = 0 To Dispatch.CommandNumMap.Length - 1
                If Dispatch.CommandNumMap(ii) = QuickSwitch.serialization.CommandName.QuickSwitch Then
                    cmdnum = ii
                    Exit For
                End If
            Next
            Dim ds As New DNSTools.DgnStrings
            ds.Add(Me.tbSwitchNum.Text)
            Dispatch.CommandRecognize("quick switch", cmdnum, "", ds)
        Else
            Dispatch.ShowTasks()
        End If

    End Sub


    Private Sub btnTBSwitch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTBSwitch.Click
        If My.MySettings.Default.SpeechEnabledAtStartup Then
            Dim cmdnum As Integer
            For ii As Integer = 0 To Dispatch.CommandNumMap.Length - 1
                If QuickSwitch.serialization.CommandName.TaskBar = Dispatch.CommandNumMap(ii) Then
                    cmdnum = ii
                    Exit For
                End If
            Next
            Dim ds As New DNSTools.DgnStrings
            ds.Add(Me.tbSwitchNum.Text)
            Dispatch.CommandRecognize("TaskBar fake", cmdnum, "", ds)
        Else
            Dispatch.SwitchToTaskBar(CInt(Me.tbSwitchNum.Text))
        End If
    End Sub




    Private Sub btnShowTasksSwitch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowTasksSwitch.Click
        If My.MySettings.Default.SpeechEnabledAtStartup Then
            Dim cmdnum As Integer
            For ii As Integer = 0 To Dispatch.CommandNumMap.Length - 1
                If QuickSwitch.serialization.CommandName.ChooseTask = Dispatch.CommandNumMap(ii) Then
                    cmdnum = ii
                    Exit For
                End If
            Next
            Dim ds As New DNSTools.DgnStrings
            ds.Add(Me.tbSwitchNum.Text)
            Dispatch.CommandRecognize("ChooseTask fake", cmdnum, "", ds)
        Else
            Dispatch.SwitchToTaskBar(CInt(Me.tbSwitchNum.Text) - 1)
        End If

    End Sub

    Private _init As Boolean = True
    Private Sub TestingForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Util.Misc.EnableVisualStyles(Me)
        chkSpeechEnabledAtStartup.Checked = My.MySettings.Default.SpeechEnabledAtStartup
        chkEnableQS.Checked = Dispatch.SpeechCommandsEnabled
        _init = False
    End Sub

    Private Sub chkSpeechEnabled_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkSpeechEnabledAtStartup.CheckedChanged
        If _init Then Exit Sub
        My.MySettings.Default.SpeechEnabledAtStartup = chkSpeechEnabledAtStartup.Checked
    End Sub
    Private Sub chkEnableQS_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkEnableQS.CheckedChanged
        If _init Then Exit Sub
        Dispatch.SpeechCommandsEnabled = chkEnableQS.Checked
    End Sub


End Class
